const KoaRouter = require('koa-router')
const { getLogin, getChapCode, findByPhone, uploadFile, updateUserInfo } = require('../controllers/sysController')
const { secret } = require('../utils/jwt') // JWT 密钥
const jwt = require('koa-jwt')({ secret })
const upload = require('../middleware/upload')

const router = new KoaRouter({
    // prefix: '/v1/sys'
})

router.post('/v1/sys/login', getLogin)
router.get('/v1/sys/chaCode/:tel', getChapCode)
router.get('/v1/info/', jwt, findByPhone)
router.post('/v1/upload', upload.single('file'), uploadFile)
router.put('/v1/info/', updateUserInfo)

module.exports = router
